package com.example.springbootclass52.stbu;

import com.example.springbootclass52.utils.RestResponse;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping("/{id}")
    public UserBean getUserById(@PathVariable int id) {
        UserBean userBean = new UserBean();
        userBean.setStuid(id);
        userBean.setStuname("sam");
        userBean.setGrade(4);
        userBean.setDept("计科");
        return userBean;
    }

    @PostMapping("")
    public RestResponse getUserByNameAndPassword(@RequestBody UserBean userBean){

        //根据用户名和密码查询数据

        UserBean userBean1 = new UserBean();
//        userBean.setStuid(id);
        userBean1.setStuname(userBean.getStuname());
        userBean1.setGrade(4);
        userBean1.setDept("计科");
        return RestResponse.ok(userBean1);
    }

    @PostMapping("")
    public UserBean addUser(@RequestBody  UserBean userBean) {
        return userBean;
    }
}
